# transcor - 
# procedure to correct for the different fiber transmissions
# it is basically a division of object gaussian amplitudes
# by the unmasked flat gaussian amplitudes

# it is assumed that mask and calfib have already run.  

procedure transcor(input,output,imcor)

char    input         {prompt="Images to be corrected"}
char    output        {prompt="Output images"}
char    imcor         {prompt="Fiber transmission calibration - unmasked flat"}

begin

int i,j 

# iraf doesn't like we use the parameter variables within the script
# so here we make a copy of them to a new variable 
# whose name has an n added to the beginning of the name of each of them
# 
char n_input
char n_output
char n_imcor

n_input = input
n_output = output
n_imcor = imcor

if ( access("lifu.sec1") )
   delete("lifu.sec1",verify=no)
if ( access("lifu.sec2") )
   delete("lifu.sec2",verify=no)
if ( imaccess(n_imcor//".nm") )
   imdelete(n_imcor//".nm",verify=no)
sections(images=n_input,>>"lifu.sec1")
sections(images=n_output,>>"lifu.sec2")

imexpr(expr="c/mean(c)",output=n_imcor//".nm",c=n_imcor)
imarith(operand1="@lifu.sec1",op="/",operand2=n_imcor//".nm",result="@lifu.sec2")

end
